package com.credit.jumu.playcard.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.credit.jumu.playcard.R;
import com.credit.jumu.playcard.adapter.HomeListAdapter;
import com.credit.jumu.playcard.bean.HomeInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/10/21/021.
 */
//通知
public class MessageNoticeFragment extends Fragment {
	ListView noticelist;
	ImageView notice_nodata;
	TextView notice_nodatatext;
	private List<HomeInfo> mlistInfo = new ArrayList<HomeInfo>();

	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_notice, null);
		setInfo();
		initView(view);
		return view;
	}

	private void initView(View view) {
		noticelist = view.findViewById(R.id.noticelist);
		noticelist.setAdapter(new HomeListAdapter(mlistInfo, getActivity()));
		notice_nodata = view.findViewById(R.id.notice_nodata);
		notice_nodatatext = view.findViewById(R.id.notice_nodatatext);
		if (mlistInfo.size() == 0) {
			notice_nodata.setVisibility(View.VISIBLE);
			notice_nodatatext.setVisibility(View.VISIBLE);
		} else {
			notice_nodata.setVisibility(View.GONE);
			notice_nodatatext.setVisibility(View.GONE);
		}
	}

	public void setInfo() {
		mlistInfo.clear();
		int i = 0;
		while (i < 0) {
			HomeInfo information = new HomeInfo();
			information.setId(1000 + i);
			information.setTitle("通知" + i);
			information.setDetails("详细信息" + i);
			information.setAvatar(R.mipmap.tab1_normal);

			mlistInfo.add(information); //将新的info对象加入到信息列表中
			i++;
		}
	}
}
